package foo.sample;

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;

import freedom.sample.ws.service.BookService;

public class JaxwsClientTest2 {
    static final Log logger = LogFactory.getLog(JaxwsClientTest2.class);

    static String wsdlAddr = "http://127.0.0.1:8080/xfire-server/services/BookService?wsdl";
    static String tns = "http://service.ws.sample.freedom";

    /**
     * 不推荐此法： 需要严格遵守服务端的接口类及涉及实体类的定义； 且为匿名访问
     */
    @Test
    public void call() {
        try {
            Service service = Service.create(new URL(wsdlAddr), new QName(tns, "BookService"));
            BookService bookService = service.getPort(new QName(tns, "BookServiceHttpPort"), BookService.class);
            System.out.println(bookService.sayHello("Jadyer"));
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }

}
